package com.jk1123;

import com.jk1123.dotdog.http.HttpServletRequest;
import com.jk1123.dotdog.http.HttpServletResponse;
import com.jk1123.dotdog.http.Servlet;
import com.jk1123.dotdog.server.DotDog;
import com.jk1123.dotdog.server.ServletContainer;

import java.nio.ByteBuffer;

/**
 * Hello world!
 */
public class App {
    public static void main(String[] args) {


        DotDog dotDog = new DotDog(9999);
        ServletContainer container = dotDog.getServletContainer();

        container.register("/cn", new Servlet() {
            @Override
            public void service(HttpServletRequest request, HttpServletResponse response) {

                String name = request.getParameter("name");


                System.out.println(name);
                response.write("<!DOCTYPE html>\n" +
                        "<html lang=\"en\">\n" +
                        "<head>\n" +
                        "    <meta charset=\"UTF-8\">\n" +
                        "    <title>这个是一个测试的页面</title>\n" +
                        "</head>\n" +
                        "<body>\n" +
                        "    <div>\n" +
                        "        哈哈哈啊哈哈哈"+
                        "    </div>\n" +
                        "</body>\n" +
                        "</html>");
            }
        });
        dotDog.start();
    }
}
